package factory_method

type Pay interface {
	Pay() string
}

type PayFactory interface {
	CreatePay() Pay
}

type AliPayFactory struct {
}

func (AliPayFactory) CreatePay() Pay {
	return AliPay{}
}

type WechatPayFactory struct{}

func (WechatPayFactory) CreatePay() Pay {
	return WechatPay{}
}

type ApplePayFactory struct{}

func (ApplePayFactory) CreatePay() Pay {
	return ApplePay{}
}

type AliPay struct{}

func (AliPay) Pay() string {
	return "支付宝支付"
}

type WechatPay struct{}

func (WechatPay) Pay() string {
	return "微信支付"
}

type ApplePay struct{}

func (ApplePay) Pay() string {
	return "苹果支付"
}

func NewPayFactory(typ int) Pay {
	var factory PayFactory
	switch typ {
	case 1:
		factory = AliPayFactory{}
	case 2:
		factory = WechatPayFactory{}
	case 3:
		factory = ApplePayFactory{}
	default:
		factory = AliPayFactory{}
	}
	return factory.CreatePay()
}
